﻿using System;

namespace SvnFlow
{
    public class SvnLogMessage
    {
        public long Revision { get; set; }
        public string Author { get; set; }
        public DateTime Time { get; set; }
        public string Message { get; set; }

        public new string ToString()
        {
            return String.Format("Original {0}: {1} | {2}\r\n{3}",
                Revision, Author, Time.ToString(SvnHelper.TimeFormat), Message);
        }

        public bool Equals(SvnLogMessage other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;

            return
                other.Revision == Revision
                && other.Time == Time
                && other.Author == Author
                && other.Message == Message;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;

            var obj1 = obj as SvnLogMessage;
            if (ReferenceEquals(null, obj1)) return false;

            return Equals(obj1);
        }

        public override int GetHashCode()
        {
            return (Revision + "|" + Time + "|" + Author + "|" + Message).GetHashCode();
        }
    }
}
